<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style type="text/css">
        body {
            background-color: #fff;
        }

        #main {
            background-color: #fff;
        }

        .wrap {
            display: flex;
            width: 100%;
            overflow: hidden;
            padding: 6px 15px;
            box-sizing: border-box;
        }

        .header_center {
            width: auto;
            display: flex;
            height: 32px;
        }

        .header_center span {
            display: inline-block;
            float: left;
        }

        .header_center span:first-child {
            width: auto;
            max-width: 90px;
            height: 25px;
            font-size: 16px;
            color: #FFFFFF;
            margin-top: 3.5px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-weight: bolder;
        }

        .header_center span:last-child {
            width: 18px;
            height: 18px;
            background: url(./image/main_sel_city.png) no-repeat;
            background-size: 100% 100%;
            background-position: center;
            margin-top: 6px;
        }

        .header_left {
            width: 100%;
            flex: 1;
            height: 32px;
            /* display: flex; */
            line-height: 32px;
            /* background: #F4F4F4; */
            border-radius: 17px;
            /* margin-left: 15px; */
            text-align: center;
            color: #333333;
            /*font-weight: bolder;*/
            font-size: 17px;
        }

        .header_left .search_icon {
            width: 16px;
            height: 16px;
            margin-top: 8px;
            margin-left: 10px;
        }

        .header_left .search_icon img {
            width: 100%;
            height: 100%;
        }

        .header_left .search_input {
            width: 100%;
            flex: 1;
            height: 20px;
            margin-top: 7px;
            margin-left: 5px;
        }

        .header_left .search_input input {
            height: 100%;
            line-height: 20px;
            font-size: 14px;
        }

        .header_right {
            width: 22px;
            height: 22px;
            margin-top: 4px;
            /*margin-left: 15px;*/
            background: url(../../image/back_arrow.png) no-repeat;
            background-size: 22px 22px;
            background-position: center;
            padding-right: 5px;
            position: relative;
        }

        .scan {
            background: url(../../image/scan.png) no-repeat;
            background-size: 17px 17px;
            background-position: center;
        }

        #idx {
            background-color: #fff;
        }

        footer {
            width: 100%;
            padding: 0 27.5px;
            background: #fff!important;
            box-sizing: border-box;
            /*opacity: 0.1;*/
        }

        .aui-bar-tab {
            position: fixed;
            top: auto;
            padding: 5px 27.5px;
            table-layout: fixed;
            justify-content: space-between;
            display: flex;
            background-color: #fff!important;
        }

        .aui-bar-tab .share {
            height: 44px;
            background: #0157E7;
            border-radius: 22px 0px 0px 22px;
            line-height: 44px;
            font-size: 16px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
            flex: 1;
        }

        .aui-bar-tab .getcoupon {
            height: 44px;
            background: #3179EB;
            border-radius: 0px 22px 22px 0px;
            line-height: 44px;
            font-size: 16px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
            flex: 1;
        }
    </style>
</head>

<body>
    <div id="app">
        <div id="idx">
            <div id="main">
                <header class="wrap" id="header_index">
                    <div class="header_right" @click='apo.closeWin()'></div>
                    <div class="header_left">饿了么</div>
                </header>
            </div>
        </div>
        <footer class="aui-bar aui-bar-tab" id="footer">
            <div class="share" @click='shareGetMoney(0)'>分享</div>
            <div class="getcoupon" @click='shareGetMoney(1)'>领券省钱</div>
        </footer>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript">
    apiready = function() {
        var header = $api.byId('idx');
        var footer = $api.byId('footer');
        var footerH = $api.offset(footer).h;

        var headerH = $api.fixStatusBar(header);
        api.openFrame({
            name: 'ele_page_frame',
            url: './ele_page_frame.html',
            rect: {
                marginTop: headerH,
                marginBottom: footerH + api.safeArea.bottom, // main页面距离win底部的高度
                w: 'auto'
            },
            bounces: true,
            bgColor: '#FAF9F9',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });

    };
    var vm = new Vue({
        el: "#app",
        data: {

        },
        methods: {
            shareGetMoney: function(index) {
                api.ajax({
                    url: cl.apiServer + 'tb/activityLink',
                    method: 'post',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8',
                        token:cl.userToken
                    },
                    data: {
                        body: {
                          "version":cl.deviceInfo().appVersion,
                          "mobileInfo":cl.systemType(),
                            "platform": "2",
                            "promotionSceneId": "1571715733668",
                            "title": "拼手速，抢饿了么大额红包！",
                            "unionId": "饿了么福利红包每日领"
                        }
                    }
                }, function(ret, err) {
                    console.log(JSON.stringify(ret))
                    if (ret.code == 0) {
                      if(index==0){
                        cl.openAlert({
                            title: ret.data.Tpwd,
                            content: '复制淘口令,打开手机淘宝，抢饿了么大额红包！',
                            rightBtnTitle: '立即复制'
                        }, function(res) {
                            if (res.eventType === "right") {
                                var clipBoard = api.require('clipBoard');
                                clipBoard.set({
                                    value: ret.data.longTpwd
                                }, function(ret, err) {
                                    if (ret) {
                                        // alert(JSON.stringify(ret));
                                        if (ret.status) {
                                            clipBoard.get(function(ret, err) {
                                                if (ret) {
                                                    cl.toast({
                                                        msg: '复制成功'
                                                    })
                                                } else {
                                                    // alert(JSON.stringify(err));
                                                }
                                            });
                                        }
                                    } else {
                                        alert(JSON.stringify(err));
                                    }
                                });
                            }
                        });
                      }else{
                        cl.openWin({
                            name: '../../brower',
                            pageParam: {
                                link:ret.data.click_url
                            }
                        })
                      }

                    }
                })
            }
        }
    })
</script>

</html>
